package com.msb.dongbao.portal.web.controller;

import com.msb.dongbao.common.base.result.ResultWrapper;
import com.msb.dongbao.ums.dto.UserMemberDto;
import com.msb.dongbao.ums.entity.UmsMember;
import com.msb.dongbao.ums.service.UmsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author 马士兵教育:chaopengfei
 * @date 2020/12/29
 */
@RestController
@RequestMapping("/user-member")
public class UserMemberController {

	@Autowired
	UmsMemberService umsMemberService;

	@GetMapping("/hello")
	public String hello(){
		return "hello";
	}

	@PostMapping("/register")
	public ResultWrapper register(@RequestBody UserMemberDto userMemberDto){
		umsMemberService.register(userMemberDto);
		return ResultWrapper.getSuccessBuilder(null).build();
	}

	@RequestMapping("/login")
	public ResultWrapper login(@RequestBody UserMemberDto userMemberDto) {
		umsMemberService.login(userMemberDto);
		return ResultWrapper.getSuccessBuilder(null).build();
	}

	@RequestMapping("/getUserByName")
	public ResultWrapper<UmsMember> getUserByName(@RequestBody String userName) {
		UmsMember umsMember = umsMemberService.getUserByName(userName);
		return ResultWrapper.getSuccessBuilder(umsMember).build();
	}
}
